<template>
  <div class="index">
    <NavBar/>
    <div class="settingAuth user infoSet dashboard-head">
      <div>
        <div class="head item">
          <div class="container">
            <div class="photo photo-level">
              <img :src="me.sysUser.avatar">
              <span :class="[`level`,`level_${me.sysUser.authType}`]"></span>
            </div>
            <div v-if="me.sysUser.authType==='0'||!me.sysUser.authType" class="name">
              <h1 class="ftz24">{{me.sysUser.userAccount}}</h1>
            </div>
            <div v-if="me.sysUser.authType === '1'||me.sysUser.authType === '2'||me.sysUser.authType === '3'" class="name">
              <div>
                <span class="ftz24">{{me.sysUser.authName}}</span>
                <i>我的主页</i>
              </div>
              <div>
                <span>关注 {{me.focusNum}}</span>
                <span>｜</span>
                <span>粉丝 {{me.fansNum}}</span>
              </div>
            </div>
            <div class="fr info">
              <ul>
                <li>
                  <span class="ftz16">{{me.viewpointNum}}篇</span>
                  <p>观点</p>
                </li>
                <li>
                  <span class="ftz16">{{me.planNum}}篇</span>
                  <p>计划</p>
                </li>
                <li>
                  <span class="ftz16">{{me.answerNum}}次</span>
                  <p>回答</p>
                </li>
                <li>
                  <span class="ftz16">{{me.subscriptionNum}}次</span>
                  <p>订阅量</p>
                </li>
                <li>
                  <span class="ftz16">{{me.incomeAll}}中亿币</span>
                  <p>收益</p>
                  <!-- userId:{{me.sysUser.userId}} -->
                </li>
              </ul>
            </div>
          </div>
        </div>
        <div class="container-user">
          <div class="con w82 item fr">
            <div class="item-h layui-nav" lay-filter>
              <a href="javascript:void(0)" @click="tagView = 'password'" class="layui-nav-item ftz16" :class="{'layui-this': tagView === 'password'}">修改密码</a>
              <a href="javascript:void(0)" @click="tagView = 'zhifu'" class="layui-nav-item ftz16" :class="{'layui-this': tagView === 'zhifu'}">支付宝实名认证</a>
              <a href="javascript:void(0)" @click="linkToUser()" class="layui-nav-item ftz16">个人资料</a>
            </div>
            <div class="infoset-c">
              <transition name="slideRightInLeftOut" mode="out-in">
                <keep-alive>
                  <component :is="menu[tagView]"></component>
                </keep-alive>
              </transition>
            </div>
          </div>
          <div class="w15 item fl">
            <SideBar2/>
          </div>
        </div>
      </div>
    </div>
    <Footer/>
  </div>
</template>
<script>
import NavBar from '@/components/nav-bar'
import SideBar2 from '@/components/side-bar2'
import Footer from '@/components/footer'
import Password from './password'
import Zhifu from './zhifu'
import { mapState } from 'vuex'
export default {
  components: {
    NavBar,
    Footer,
    SideBar2
  },
  data () {
    return {
      viewData: {},
      total: null,
      menu: {
        password: Password,
        zhifu: Zhifu
      },
      tagView: 'password',
      loading: false
    }
  },
  created () {
    if (this.curTab && this.menu[this.curTab]) {
      this.tagView = this.curTab
    }
  },
  computed: {
    // 来源网址
    url () {
      return this.$route.query.url || ''
    },
    curRoute () {
      return this.$route.path
    },
    curTab () {
      return this.$route.query.tab
    },
    ...mapState({
      me: state => state.me
    })
  },
  methods: {
    linkToUser () {
      var winHandler = window.open('', '_blank')
      if (/\.zhongyi9999\.com/.test(window.location.href)) {
        winHandler.location.href = '//open.zhongyi9999.com/#/account/index?type=info'
      }
      if (/\.hxkjtest\.com/.test(window.location.href)) {
        winHandler.location.href = '//open.hxkjtest.com/#/account/index?type=info'
      }
      if (/localhost/.test(window.location.href)) {
        winHandler.location.href = '//localhost:8088/#/account/index?type=info'
      }
    }
  }
}
</script>
<style lang="scss">
@import "../../style/res/user";
@import "../../style/res/infoSet";
</style>
